<html>
<head><meta charset="utf-8"><title>Installing cargo with a different prefix · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Installing.20cargo.20with.20a.20different.20prefix.html">Installing cargo with a different prefix</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="204292181"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Installing%20cargo%20with%20a%20different%20prefix/near/204292181" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jakub Kądziołka <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Installing.20cargo.20with.20a.20different.20prefix.html#204292181">(Jul 18 2020 at 08:57)</a>:</h4>
<p>I want to install cargo to a different prefix than rustc itself. We currently build the rust package for Guix with the following commands:</p>
<div class="codehilite"><pre><span></span><code>./x.py build
./x.py build src/tools/cargo
./x.py -j1 test -vv
./x.py -j1 test src/tools/cargo
./x.py install
# change the prefix variable in config.toml
./x.py install cargo
</code></pre></div>


<p>For Rust 1.33 and earlier, this last commands <a href="http://ci.guix.gnu.org/log/w9zd0qn05hbs778agw2pxcvpvxdw3ycd-rust-1.33.0">builds barely anything</a>:</p>
<div class="codehilite"><pre><span></span><code>Building stage0 codegen artifacts (x86_64-unknown-linux-gnu -&gt; x86_64-unknown-linux-gnu, llvm)
   Compiling rustc_codegen_llvm v0.0.0 (/tmp/guix-build-rust-1.33.0.drv-0/rustc-1.33.0-src/src/librustc_codegen_llvm)
    Finished release [optimized] target(s) in 33.42s
...
Building stage1 codegen artifacts (x86_64-unknown-linux-gnu -&gt; x86_64-unknown-linux-gnu, llvm)
   Compiling rustc_codegen_llvm v0.0.0 (/tmp/guix-build-rust-1.33.0.drv-0/rustc-1.33.0-src/src/librustc_codegen_llvm)
    Finished release [optimized] target(s) in 31.30s
</code></pre></div>


<p>However, following <a href="https://github.com/rust-lang/rust/pull/57680">PR 57680</a>, the whole stage1 <a href="http://ci.guix.gnu.org/log/imiv2bahk5vfmxs1wrws37rx7rx431qm-rust-1.34.1">is built again</a>:</p>
<div class="codehilite"><pre><span></span><code>Building stage0 codegen artifacts (x86_64-unknown-linux-gnu -&gt; x86_64-unknown-linux-gnu, llvm)
   Compiling rustc_codegen_llvm v0.0.0 (/tmp/guix-build-rust-1.34.1.drv-0/rustc-1.34.1-src/src/librustc_codegen_llvm)
    Finished release [optimized] target(s) in 32.60s
Assembling stage1 compiler (x86_64-unknown-linux-gnu)
Building stage1 std artifacts (x86_64-unknown-linux-gnu -&gt; x86_64-unknown-linux-gnu)
   Compiling core v0.0.0 (/tmp/guix-build-rust-1.34.1.drv-0/rustc-1.34.1-src/src/libcore)
   Compiling libc v0.2.46
   Compiling compiler_builtins v0.1.5
...
</code></pre></div>


<p>Because of this, I think that the approach we are taking is not the intended method of installing cargo to a different prefix than the compiler itself. I tested <code>./x.py install cargo --keep-stage 1</code>, and while it stops the rebuild, it doesn't feel like a clean solution.</p>



<a name="204640165"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Installing%20cargo%20with%20a%20different%20prefix/near/204640165" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Installing.20cargo.20with.20a.20different.20prefix.html#204640165">(Jul 22 2020 at 08:16)</a>:</h4>
<p>I don't think there <em>is</em> an intended method of installing cargo to a different prefix than rustc. At least, I don't think it's a use case anyone has considered.</p>



<a name="204640216"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Installing%20cargo%20with%20a%20different%20prefix/near/204640216" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Installing.20cargo.20with.20a.20different.20prefix.html#204640216">(Jul 22 2020 at 08:17)</a>:</h4>
<p>People package them separately, but I don't think anyone considered the use case of different prefixes.</p>



<a name="204640288"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Installing%20cargo%20with%20a%20different%20prefix/near/204640288" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Installing.20cargo.20with.20a.20different.20prefix.html#204640288">(Jul 22 2020 at 08:18)</a>:</h4>
<p>(I do understand why guix and nix do so though. Although I wonder if the two could be in the same package.)</p>



<a name="204640345"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Installing%20cargo%20with%20a%20different%20prefix/near/204640345" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Installing.20cargo.20with.20a.20different.20prefix.html#204640345">(Jul 22 2020 at 08:19)</a>:</h4>
<p>I don't <em>think</em> cargo currently cares about its prefix, so you might be able to just move the cargo binary to the prefix you want.</p>



<a name="204645521"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Installing%20cargo%20with%20a%20different%20prefix/near/204645521" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Installing.20cargo.20with.20a.20different.20prefix.html#204645521">(Jul 22 2020 at 09:24)</a>:</h4>
<p><span class="user-mention" data-user-id="281536">@Jakub Kądziołka</span> do you need the prefix, or can you use <code>DESTDIR</code> with the install command?</p>



<a name="204645559"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Installing%20cargo%20with%20a%20different%20prefix/near/204645559" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Installing.20cargo.20with.20a.20different.20prefix.html#204645559">(Jul 22 2020 at 09:24)</a>:</h4>
<p>AFAIK we don't really use the prefix, e.g. <code>rustc</code> finds the <code>lib/rustlib</code> dir relative to itself</p>



<a name="204645580"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Installing%20cargo%20with%20a%20different%20prefix/near/204645580" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Installing.20cargo.20with.20a.20different.20prefix.html#204645580">(Jul 22 2020 at 09:25)</a>:</h4>
<p>so you might get away with just installing them in separate dirs</p>



<a name="204645667"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Installing%20cargo%20with%20a%20different%20prefix/near/204645667" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Installing.20cargo.20with.20a.20different.20prefix.html#204645667">(Jul 22 2020 at 09:26)</a>:</h4>
<p>also presumably using <code>./configure</code> is easier than creating your own <code>config.toml</code> but that's another story. I'm guessing you can't use <code>make install</code> because that won't give you control over cargo or something else</p>



<a name="204715384"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Installing%20cargo%20with%20a%20different%20prefix/near/204715384" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jakub Kądziołka <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Installing.20cargo.20with.20a.20different.20prefix.html#204715384">(Jul 22 2020 at 20:02)</a>:</h4>
<p>Well, the codegen backend uses <code>CFG_PREFIX</code>, I'm not entirely sure why. What is that for?<br>
I guess I could set prefix to <code>/</code> and use <code>DESTDIR</code>, but, ehh...</p>



<a name="204715570"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Installing%20cargo%20with%20a%20different%20prefix/near/204715570" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jakub Kądziołka <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Installing.20cargo.20with.20a.20different.20prefix.html#204715570">(Jul 22 2020 at 20:04)</a>:</h4>
<p>(the 'proper' variable to set here would be the prefix and not destdir, since the binaries <em>will</em> run at the path in question when they get installed)</p>



<a name="204759742"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Installing%20cargo%20with%20a%20different%20prefix/near/204759742" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Installing.20cargo.20with.20a.20different.20prefix.html#204759742">(Jul 23 2020 at 04:28)</a>:</h4>
<p><span class="user-mention" data-user-id="281536">@Jakub Kądziołka</span> looks like it's for <code>-C rpath</code> only</p>



<a name="204759774"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Installing%20cargo%20with%20a%20different%20prefix/near/204759774" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Installing.20cargo.20with.20a.20different.20prefix.html#204759774">(Jul 23 2020 at 04:30)</a>:</h4>
<p><span class="user-mention" data-user-id="232545">@Joshua Nelson</span> anyway Cargo doesn't use the prefix AFAICT so you can set it to the value <code>rustc</code> might need and then use <code>DESTDIR</code> to install Cargo separately</p>



<a name="204759821"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Installing%20cargo%20with%20a%20different%20prefix/near/204759821" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Installing.20cargo.20with.20a.20different.20prefix.html#204759821">(Jul 23 2020 at 04:30)</a>:</h4>
<p>Wrong Josh ;)</p>



<a name="204759824"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Installing%20cargo%20with%20a%20different%20prefix/near/204759824" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Installing.20cargo.20with.20a.20different.20prefix.html#204759824">(Jul 23 2020 at 04:30)</a>:</h4>
<p>ARGH</p>



<a name="204759825"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Installing%20cargo%20with%20a%20different%20prefix/near/204759825" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Installing.20cargo.20with.20a.20different.20prefix.html#204759825">(Jul 23 2020 at 04:30)</a>:</h4>
<p>wrong Jo!</p>



<a name="204759828"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Installing%20cargo%20with%20a%20different%20prefix/near/204759828" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Installing.20cargo.20with.20a.20different.20prefix.html#204759828">(Jul 23 2020 at 04:30)</a>:</h4>
<p>not even. wrong J</p>



<a name="204759843"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Installing%20cargo%20with%20a%20different%20prefix/near/204759843" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Installing.20cargo.20with.20a.20different.20prefix.html#204759843">(Jul 23 2020 at 04:31)</a>:</h4>
<p>Maybe I need to change my name so it's easier for you to mention the right person <span aria-label="rofl" class="emoji emoji-1f923" role="img" title="rofl">:rofl:</span></p>



<a name="204759844"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Installing%20cargo%20with%20a%20different%20prefix/near/204759844" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Installing.20cargo.20with.20a.20different.20prefix.html#204759844">(Jul 23 2020 at 04:31)</a>:</h4>
<p>why is Zulip's @ bad? it defaults to <em>something</em> that's neither alphabetical nor based on the topic you're in</p>



<a name="204759851"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Installing%20cargo%20with%20a%20different%20prefix/near/204759851" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Installing.20cargo.20with.20a.20different.20prefix.html#204759851">(Jul 23 2020 at 04:31)</a>:</h4>
<p>It's probably something dumb like 'previous times mentioned'</p>



<a name="204759852"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Installing%20cargo%20with%20a%20different%20prefix/near/204759852" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Installing.20cargo.20with.20a.20different.20prefix.html#204759852">(Jul 23 2020 at 04:31)</a>:</h4>
<p><span class="user-mention" data-user-id="232545">@Joshua Nelson</span> there's 2 other people between you and <span class="user-mention" data-user-id="281536">@Jakub Kądziołka</span></p>



<a name="204760036"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Installing%20cargo%20with%20a%20different%20prefix/near/204760036" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Installing.20cargo.20with.20a.20different.20prefix.html#204760036">(Jul 23 2020 at 04:36)</a>:</h4>
<p><span class="user-mention" data-user-id="281536">@Jakub Kądziołka</span> anyway it looks like the rpath thing, which isn't even on by default, is why. presumably some distros want absolute RPATHs on Rust binaries/dylibs? the fallback one that uses <code>CFG_PREFIX</code> is only for, like, dynamically linking libstd mostly?</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>